home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE05 / EDSSPELL / EDSSPELL.ZIP / SPELLINT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-11-17  |  3.8 KB  |  128 lines

  1. unit SpellInt;
  2.  {-interface unit for SPELLER.DLL}
  3. interface
  4. uses
  5.   SysUtils, WinProcs, Classes;
  6.  
  7. const
  8.   MaxSuggest = 10;  {don't change this!!!}
  9.  
  10. function dllOpenDictionary(FileName : string) : Boolean;
  11.   {-Opens the specified dictionary; Returns TRUE if successful}
  12. function dllInDictionary(AWord: String) : Boolean;
  13.   {-Returns TRUE if AWord is in the dictionary}
  14. function dllAddWord(AWord : String) : Boolean;
  15.   {-Adds AWord to User Dictionary; Returns TRUE if successful}
  16. function  dllSuggestWords(AWord: String; NumSuggest: byte): TStringList;
  17.   {-Suggests words; Returns nil if unsuccessful}
  18. procedure dllDeleteUserWords;
  19.   {-Deletes all word in User Dictionary}
  20. procedure dllCloseDictionary;
  21.   {-Closes the currently open dictionary}
  22.  
  23. implementation
  24.  
  25. function Changer (S: String): String;
  26.   {-changes the word for use by the dictionary}
  27. var
  28.   i:      integer;
  29.   CWord:  String;
  30.   ch:     Char;
  31. begin
  32.   S := S + #0;
  33.   {AnsiToOem (@S[1], @S[1]);}
  34.   {make a copy of the word}
  35.   CWord := S;
  36.   {blank the word to receive the changed word, since it is a variable}
  37.   S := '';
  38.   {rebuild the word ready for the dictionary}
  39.   for i := 1 to (length(Cword)) do
  40.   begin
  41.     ch := Cword[i];
  42.     {case of accented a,e,i,o,u,u,n,N.  Using ASCII #.}
  43.     case ch of
  44.       #160 : S := S + 'a' + '/';
  45.       #130 : S := S + 'e' + '/';
  46.       #161 : S := S + 'i' + '/';
  47.       #162 : S := S + 'o' + '/';
  48.       #163 : S := S + 'u' + '/';
  49.       #129 : S := S + 'u' + '*';
  50.       #164 : S := S + 'n' + '/';
  51.       #165 : S := S + 'n' + '*';
  52.      'a'..'z','A'..'Z', '''' :   S := S + CH;
  53.     end; { case }
  54.   end; { next i }
  55.   S := UpperCase (S);
  56.   Result  := S;
  57. end; {changer}
  58.  
  59. type
  60.   StrsType = String[30];
  61.   ShortList = Array [1..MaxSuggest] of StrsType;
  62.  
  63. function _OpenDictionary (FileName : string) : Boolean;
  64.   Far; External 'SPELLER' index 1;
  65. function _InDictionary (AWord : String) : Boolean;
  66.   Far; External 'SPELLER' index 2;
  67. function _AddWord(AWord: String; Sorted : Boolean) : Boolean;
  68.   Far; External 'SPELLER' index 3;
  69. procedure _SuggestWords(AWord: String; var SW: ShortList; NumSuggest: byte);
  70.   Far; External 'SPELLER' index 4;
  71. procedure _DeleteUserWords;
  72.   Far; External 'SPELLER' index 5;
  73. procedure _CloseDictionary;
  74.   Far; External 'SPELLER' index 6;
  75. function _Changer (S: String): String;
  76.   Far; External 'SPELLER' index 7;
  77. function _AdjustCase (S, PictureSt: String): string;
  78.   Far; External 'SPELLER' index 8;
  79. procedure _Simulate(var S : String; DNewstr : string);
  80.   Far; External 'SPELLER' index 9;
  81.  
  82. function dllOpenDictionary(FileName : string) : Boolean;
  83.   {-Opens the specified dictionary; Returns TRUE if successful}
  84. begin
  85.   Result := _OpenDictionary (FileName);
  86. end;  { dllOpenDictionary }
  87.  
  88. function dllInDictionary(AWord: String) : Boolean;
  89.   {-Returns TRUE if AWord is in the dictionary}
  90. begin
  91.   AWord  := Changer (AWord);
  92.   Result := _InDictionary (AWord);
  93. end;  { dllInDictionary }
  94.  
  95. function dllAddWord(AWord : String) : Boolean;
  96.   {-Adds AWord to User Dictionary; Returns TRUE if successful}
  97. begin
  98.   AWord  := Changer (AWord);
  99.   Result := _AddWord (AWord, FALSE);
  100. end;  { dllAddWord }
  101.  
  102. function dllSuggestWords(AWord: String; NumSuggest: byte): TStringList;
  103.   {-Suggests words; Returns nil if unsuccessful}
  104. var
  105.   Listing: ShortList;
  106.   i:       byte;
  107. begin
  108.   Result := TStringList.Create;
  109.   _SuggestWords (AWord, Listing, NumSuggest);
  110.   for i := 1 to NumSuggest do
  111.     if Listing[i]<>'' then
  112.       Result.Add (_AdjustCase (Listing[i], AWord));
  113. end;  { dllSuggestWords }
  114.  
  115. procedure dllDeleteUserWords;
  116.   {-Deletes all word in User Dictionary}
  117. begin
  118.   _DeleteUserWords;
  119. end;  { dllDeleteUserWords }
  120.  
  121. procedure dllCloseDictionary;
  122.   {-Closes the currently open dictionary}
  123. begin
  124.   _CloseDictionary;
  125. end;  { dllCloseDictionary }
  126.  
  127. end.  { SpellInt }
  128.